package cn.hs.service.impl;

import cn.hs.entity.Heartmark;
import cn.hs.mapper.HeartmarkMapper;
import cn.hs.service.HeartmarkService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName HeartmarkServiceImpl
 * @Description TODO
 * @Author mujiale
 * @Date 2024年10月23日 19:47
 * @Version 1.0
 */
@Service
public class HeartmarkServiceImpl implements HeartmarkService {

    @Autowired
    private HeartmarkMapper heartmarkMapper;

    /**
     * 查询所有并分页
     * @param heartmark
     * @return
     */

    @Override
    public PageInfo<Heartmark> selectAll(Integer pageNum, Integer pageSize, Heartmark heartmark) {
        PageHelper.startPage(pageNum,pageSize);
        List<Heartmark> heartmarks = heartmarkMapper.selectAll(heartmark);
        PageInfo pageInfo = new PageInfo(heartmarks);
        return pageInfo;
    }

    @Override
    public int insert(Heartmark heartmark) {
        return heartmarkMapper.insert(heartmark);
    }

    @Override
    public int delete(Integer id) {
        return heartmarkMapper.delete(id);
    }

    @Override
    public int update(Heartmark heartmark) {
        return heartmarkMapper.update(heartmark);
    }

    @Override
    public Heartmark selectById(Integer id)
    {

        return  heartmarkMapper.selectById(id);
    }
}
